﻿// This code is released under the BSD license.
namespace PugLib.UnitTest
{
    #region

    using System;
    using Benchmarks;
    using Extensions;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    #endregion

    /// <summary>
    ///This is a test class for BenchmarksTest and is intended
    ///to contain all BenchmarksTest Unit Tests
    ///</summary>
    [TestClass]
    public class BenchmarksTest
    {
        /// <summary>
        ///A test for Benchmarks Constructor
        ///</summary>
        [TestMethod]
        public void BenchmarksTestMethod()
        {
            TestResultCollection testResults = new TestResultCollection();
            Statics.ItemCount = 500;
            Statics.Max = 500;
            Statics.PythagoreanMax = 300;
            Statics.MapTestCount = Int32.MaxValue / 400;

            testResults.Add(Threads.PugParallelMap2());

            testResults.Add(Threads.ListIntGenericsThreads(8));
            testResults.Add(Threads.ListIntGenericsThreads(16));
            testResults.Add(Threads.ListIntGenericsThreads(55));
            testResults.Add(Threads.ListIntGenericsBackgroundWorker(8));

            testResults.Add(Threads.ListIntLinqSimplest());
            testResults.Add(Threads.ListIntLinqFastLambda());
            testResults.Add(Threads.ListIntLinqOldStyle());


            testResults.Add(Loops.ArrayFor());
            testResults.Add(Loops.ArrayForEachExtension());

            testResults.Add(Loops.ArrayForEach());
            testResults.Add(Loops.ListToArray());
            testResults.Add(Loops.ListIntForCachingCount());
            testResults.Add(Loops.ListIntForUsingCount());
            testResults.Add(Loops.ListIntForEach());
            testResults.Add(Loops.ListIntGenericsForEachDelegate());
            testResults.Add(Loops.ListIntGenericsForEachLambda());
            testResults.Add(Loops.ListIntGenericsForEachCountOuter());

            testResults.Sort();
            testResults.ToConsoleLine();
        }

        [TestMethod]
        public void TestPythagorean()
        {
            Maths.PythagoreanParallelOuter();
            Maths.PythagoreanSerial();
            Maths.PythagoreanParallelOuterAndMiddle();
        }
    }
}